<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class UpdateWechatMenu extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'wechat:update_menu';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'update wechat menu';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $app = app('wechat');
        $appid = config('wechat.app_id');

        $buttons = [
            [
                'name'  =>  '诗苑天地',
                'sub_button'    =>  [
                    ['type' =>  'view', 'name'  =>  '诗苑宣言', 'url' => get_wechat_auth_url('http://luo.minmore.com/pages/info')],
                    ['type' =>  'view', 'name'  =>  '诗友守则', 'url' => get_wechat_auth_url('http://luo.minmore.com/pages/rule')],
                ]
            ],
            [
                'name'  =>  '登录注册',
                'sub_button'    =>  [
                    ['type' =>  'view', 'name'  =>  '诗友注册', 'url' => get_wechat_auth_url('http://luo.minmore.com/register')],
                    ['type' =>  'view', 'name'  =>  '诗友登录', 'url' => get_wechat_auth_url('http://luo.minmore.com/login')],
                ]
            ],
            [
                'name'  =>  '诗友部落',
                'sub_button'    =>  [
                    ['type' =>  'view', 'name'  =>  '我的部落', 'url' => get_wechat_auth_url('http://luo.minmore.com/luo/my')],
                    ['type' =>  'view', 'name'  =>  '其他部落', 'url' => get_wechat_auth_url('http://luo.minmore.com')],
                ]
            ]
        ];

        dump($buttons);
        if($this->confirm('Do you wish to publish menu?')){
            //$app->menu->add($buttons);
        }
    }
}
